﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.BLL;
using ZX.Common;
using ZX.SYS.Library;
using ZX.CRM.Library;
using ZX.CRM.Bussiness;
using ZX.DBModule;

namespace ZX.WebApp.Crm.Customer
{
    public partial class AddActivity : BasePage
    {
        BTCrmCustomer bllCustomer = new BTCrmCustomer();
        BDatPhraseDetail bllDetail = new BDatPhraseDetail();
        protected void Page_Load(object sender, EventArgs e)
        {
            string strCustomerId = this.GetStringFromQueryString("id", "");
            //联系人
            IList<V_CrmLinkMan> listLinkMan = bllCustomer.GetLinkManInfoByCustomerId(new Guid(strCustomerId));
            if (listLinkMan != null && listLinkMan.Count > 0)
            {
                this.LinkManID.DataSource = listLinkMan;
                this.LinkManID.DataValueField = "ID";
                this.LinkManID.DataTextField = "Caption";
                this.LinkManID.DataBind();
            }
            //动作类型
            IList<DatPhraseDetail> listLinkType = bllDetail.GetDatPhraseDetailByClassValue("TelAnimal");
            if (listLinkType != null && listLinkType.Count > 0)
            {
                this.TypeID.DataSource = listLinkType;
                this.TypeID.DataValueField = "PhraseID";
                this.TypeID.DataTextField = "PhraseText";
                this.TypeID.DataBind();
            }

            bindTime();
        }
        private void bindTime()
        {
            this.PlanStartDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            this.PlanEndDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
            
            for (int i = 0; i < 24; i++)
            {
                ListItem itemHour = new ListItem();
                itemHour.Text = i < 10 ? "0" + i.ToString() : i.ToString();
                itemHour.Value = i < 10 ? "0" + i.ToString() : i.ToString();
                ddlStartMin.Items.Add(itemHour);
            }
            for (int i = 0; i < 60; i++)
            {
                ListItem itemMinute = new ListItem();
                itemMinute.Text = i < 10 ? "0" + i.ToString() : i.ToString();
                itemMinute.Value = i < 10 ? "0" + i.ToString() : i.ToString();
                ddlStartSec.Items.Add(itemMinute);
            }
            for (int i = 0; i < 24; i++)
            {
                ListItem itemHour = new ListItem();
                itemHour.Text = i < 10 ? "0" + i.ToString() : i.ToString();
                itemHour.Value = i < 10 ? "0" + i.ToString() : i.ToString();
                ddlEndMin.Items.Add(itemHour);
            }
            for (int i = 0; i < 60; i++)
            {
                ListItem itemMinute = new ListItem();
                itemMinute.Text = i < 10 ? "0" + i.ToString() : i.ToString();
                itemMinute.Value = i < 10 ? "0" + i.ToString() : i.ToString();
                ddlEndSec.Items.Add(itemMinute);
            }
        }

        public string CustomerID
        {
            get { return this.GetStringFromQueryString("id", ""); }
        }
        public string LocalDate
        { get { return DateTime.Now.ToString("yyyy-MM-dd"); } }
    }
}